Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rollup-plugin-md for security alerts and modern build #6

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

BobKerns
Copy link

The plugin is referencing downrev versions of marked and other dependencies that result in security alerts with npm and github.

This updates the dependencies, drops the use of buble, updates how rollup is called, and adds a Github action to do a CI test build.

I also suggest adding the following .github/workflows/npm.yaml file to publish to npm whenever you create a release in github. I did not include it as you may have your own workflow you prefer.

name: Node.js Package
on:
  release:
    types: [created]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      # Setup .npmrc file to publish to npm
      - uses: actions/setup-node@v1
        with:
          node-version: '14.x'
          registry-url: 'https://registry.npmjs.org'
      - run: npm install
      - run: npm publish --access public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

Comment on lines -8 to +25
const filter = createFilter( options.include || [ '**/*.md'], options.exclude );
if(options.marked){
marked.setOptions(options.marked)
}
return {
name: 'md',
const filter = createFilter( options.include || [ '**/*.md'], options.exclude );
if (options.marked) {
marked.setOptions(options.marked);
}
return {
name: 'md',

transform ( md, id ) {
if ( !ext.test( id ) ) return null;
if ( !filter( id ) ) return null;
transform ( md, id ) {
if ( !ext.test( id ) ) return null;
if ( !filter( id ) ) return null;

const data = marked( md );
return {
code: `export default ${JSON.stringify(data.toString())};`,
map: { mappings: '' }
};
}
};
const data = marked( md );
return {
code: `export default ${JSON.stringify(data.toString())};`,
map: { mappings: '' }
};
}
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation only, no code changes in this section.

var npm = require( 'rollup-plugin-node-resolve' );
var npm = require( '@rollup/plugin-node-resolve' );
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plugin moved.

test/test.js Outdated
Comment on lines 11 to 35
var generated = bundle.generate();
var code = generated.code;
var generated = bundle.generate();
var code = generated.code;

var fn = new Function( 'assert', code );
fn( assert );
var fn = new Function( 'assert', code );
fn( assert );
}

describe( 'rollup-plugin-md', function () {
it( 'converts md', function () {
return rollup.rollup({
entry: 'samples/main.js',
plugins: [ md({
marked: {
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false
}
}) ]
}).then( executeBundle );
});
it( 'converts md', function () {
return rollup.rollup({
input: 'samples/main.js',
plugins: [ md({
marked: {
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false
}
}) ]
}).then( executeBundle );
});
});
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change here is on line 21: 'entry' => 'input' to match the current rollup API. The rest is indentation.

I am not a fan of tabs, but since you set up the .eslint rules to call for it, I invoked the rules, so you would not have mixed indentation.

import buble from 'rollup-plugin-buble';

var pkg = require('./package.json')
var pkg = require('./package.json');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buble is no longer needed, and no longer works with mocha.

Comment on lines -7 to +19
entry: 'src/index.js',
plugins: [ buble({ sourceMap: true }) ],
targets: [
{
format: 'cjs',
dest: pkg['main']
},
{
format: 'es',
dest: pkg['jsnext:main']
}
],
external: external,
sourceMap: true
input: 'src/index.js',
output: [
{
format: 'cjs',
file: pkg['main'],
sourcemap: true,
exports: 'auto'
},
{
format: 'es',
file: pkg['jsnext:main'],
sourcemap: true
}
],
external: external
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rollup API has changed. This should be equivalent.

"test": "mocha test/*.js --compilers js:buble/register",
"test": "mocha test/*.js",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --compilers option is deprecated, and buble/register no longer works. Removed since it is no longer needed.

@BobKerns
Copy link
Author

This should fix issue #4.

@BobKerns
Copy link
Author

This should subsume #5; the changes are a superset.

@BobKerns
Copy link
Author

It looks like @dagda1 did a substantial amount of work on #5 since, so this is no longer a superset; perhaps even a subset.

I haven't yet reviewed his changes to see if this PR should be closed.

@dagda1
Copy link

dagda1 commented Dec 30, 2020

I haven't yet reviewed his changes to see if this PR should be closed.

@BobKerns I ended up just forking to my own repo and using some of my own packages to build, test and also use my own tsconfig base and eslint.

I did not think this repo was being maintained but if you still want me to reopen with my changes then let me know.

Apologies if I jumped the gun

@BobKerns
Copy link
Author

Apologies if I jumped the gun

Nothing to apologize for; we're both jumping in here. I don't know if it's maintained or not, @xiaofuzi has had activity in the past few days, so he may pop in here. But they haven't touched this repo in 4 years.

I was reacting to the same issues you were, but you got around to a pull request first.

It looked to me like from the commit comments like you were making it more maintainable. I hope to see this folded together under one umbrella or another.

@dagda1
Copy link

dagda1 commented Dec 30, 2020

@BobKerns I don't think anything will happen here.

Let me know if there is anything I can do.

@xiaofuzi
Copy link
Owner

there are some conflicts

dependabot bot added 4 commits December 5, 2022 11:33
Bumps [marked](https://github.com/markedjs/marked) from 1.2.7 to 4.0.10.
- [Release notes](https://github.com/markedjs/marked/releases)
- [Changelog](https://github.com/markedjs/marked/blob/master/.releaserc.json)
- [Commits](markedjs/marked@v1.2.7...v4.0.10)

---
updated-dependencies:
- dependency-name: marked
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.20...4.17.21)

---
updated-dependencies:
- dependency-name: lodash
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.1 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](gulpjs/glob-parent@v5.1.1...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
BobKerns and others added 6 commits December 5, 2022 04:02
…nt-5.1.2

Bump glob-parent from 5.1.1 to 5.1.2
…e-1.0.7

Bump path-parse from 1.0.6 to 1.0.7
…17.21

Bump lodash from 4.17.20 to 4.17.21
Bumps [minimatch](https://github.com/isaacs/minimatch) to 3.1.2 and updates ancestor dependency [mocha](https://github.com/mochajs/mocha). These dependencies need to be updated together.


Updates `minimatch` from 3.0.4 to 3.1.2
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](isaacs/minimatch@v3.0.4...v3.1.2)

Updates `mocha` from 8.2.1 to 10.1.0
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
- [Commits](mochajs/mocha@v8.2.1...v10.1.0)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
- dependency-name: mocha
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
…-and-mocha-3.1.2

Bump minimatch and mocha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants